package com.xq.spring.postprocess.container;

import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * 基础的BeanFactory测试类.
 * 
 * @author 郭凯强
 */
public class BaseBeanFactory {
	public static void main(String[] args) {
		Resource cfgResource = new ClassPathResource("cfg-postprocess-container.xml");
		// 创建默认的BeanFactory
		DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
		// 让默认的BeanFactory加载XML配置文件
		new XmlBeanDefinitionReader(beanFactory).loadBeanDefinitions(cfgResource);
		// 只能手动调用
		BeanFactoryPostProcessor postProcessor = beanFactory.getBean(CustomBeanFactoryPostProcessor.class);
		postProcessor.postProcessBeanFactory(beanFactory);
	}
}
